# Maintainer: Ray Donnelly <mingw.android@gmail.com>

_realname=installer-framework

pkgname="${MINGW_PACKAGE_PREFIX}-qt-${_realname}-git"
pkgdesc="The Qt Installer Framework used for the Qt SDK installer"
pkgver=r2180.62704a6
pkgrel=1
arch=('any')
url='http://qt-project.org/'
license=('GPL3' 'LGPL' 'FDL' 'custom')
provides=("${MINGW_PACKAGE_PREFIX}-qt-${_realname}")
makedepends=("${MINGW_PACKAGE_PREFIX}-qt5-static" "${MINGW_PACKAGE_PREFIX}-gcc"
      "${MINGW_PACKAGE_PREFIX}-make")
options=('strip' 'staticlibs')
#options=('!strip' 'debug' 'staticlibs')
source=("${_realname}"::"git://gitorious.org/${_realname}/${_realname}.git"
        "0002-add-installation-stuff-to-pro-files.patch"
        "0003-add-recursive-option-to-rmdir-operation.patch"
        "0004-add-dirExists-fuction.patch"
        "0005-Fix-RunProgram-variable-substitution.patch")
md5sums=('SKIP'
         '614046f9d32cf592c98856c195bbbba6'
         'd4ca5e1b2a30a26eaf37d69c24444587'
         '61d67ae4eee1a326fad6c0f8d2d33b7a'
         'f3a40ff3dd9f010f67101cfc41bb6fb1')

pkgver() {
  cd "$srcdir"/${_realname}
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}"/${_realname}
  git am "${srcdir}"/0002-add-installation-stuff-to-pro-files.patch
  git am "${srcdir}"/0003-add-recursive-option-to-rmdir-operation.patch
  git am "${srcdir}"/0004-add-dirExists-fuction.patch
  # Apply patch from https://bugreports.qt-project.org/browse/QTIFW-397
  git am "${srcdir}"/0005-Fix-RunProgram-variable-substitution.patch
}

build() {
  local _config
  cd "${srcdir}"/${_realname}
  if check_option "debug" "n"; then
    _config="release"
  else
    _config="debug"
  fi
  ${MINGW_PREFIX}/qt5-static/bin/qmake.exe installerfw.pro CONFIG+="${_config}" CONFIG+=no_testcase_installs
  make
}

package() {
  cd "${srcdir}"/${_realname}
  make INSTALL_ROOT="${pkgdir}${MINGW_PREFIX}" install
}
